// DMMiningParameter.h

#pragma once

#include "dmalgointerfaces.h"


using namespace System;
using namespace System::Reflection;
using namespace System::Collections;

#include "DMEnumerationWrappers.h"

namespace Microsoft
{
namespace SqlServer
{
namespace DataMining
{
namespace PluginAlgorithms
{
    public   ref class MiningParameter sealed  
    {
   
    public:
        MiningParameter(String ^ name, System::Type ^   type);
        
        MiningParameter(String ^ name, 
                        String ^ description, 
                        String ^ defaultValue, 
                        System::Boolean isRequired, 
                        System::Boolean isExposed,
                        System::Type ^   type);

        MiningParameter(String ^ name, 
                        String ^ description, 
                        String ^ defaultValue, 
                        String ^ valueEnumeration,
                        System::Boolean isRequired, 
                        System::Boolean isExposed,
                        System::Type ^   type);
        // Name
        

		property String ^ Name
		{ 
			String ^ get()
			{ 
				return m_name;
			}  
			void set(String^ value)
			{ 
				if( !m_fHasError) 
					m_name=value;
			}
		}
        
    
        // TypeName -- it is Get only, as the type name comes from the
        // from  m_type member
        

		[System::Diagnostics::CodeAnalysis::SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase")]
		property String ^ DbTypeName
		{ 
			String ^ get()
			{
				return m_typeName; 
			}
		}

        // description
        

		property String ^ Description 
		{ 
			String ^ get()
			{
				return m_description; 
			}


			void set( String ^ value )
			{
				if( !m_fHasError) 
					m_description = value;
			}
		}
        

        // defaultValue

		property String ^ DefaultValue
		{
			String ^ get() 
			{ 
				return m_defaultValue; 
			}

			void set(String ^ value)
			{
				if( !m_fHasError) 
					m_defaultValue = value;
			}
		}
        

        // valueEnumeration
        
		property String ^ ValueEnumeration
		{
			String ^ get() 
			{ 
				return m_valueEnumeration; 
			}
			void set(String ^   value) 
			{ 
				m_valueEnumeration = value; 
			}
		}

        // isExposed
        
		property System::Boolean IsExposed 
		{
			System::Boolean get() 
			{ 
				return m_isExposed; 
			}
			void set(System::Boolean   value) 
			{
				m_isExposed = value; 
			}
		}

        // isRequired
        
		property System::Boolean IsRequired
		{
			System::Boolean get() 
			{ 
				return m_isRequired; 
			}
			void set(System::Boolean   value) 
			{ 
				m_isRequired = value; 
			}
		}

        // type
        
		property System::Type ^ Type
		{
			System::Type ^ get()
			{
				return m_type;
			}
			void set(System::Type ^ value)
			{
			    m_type  =   value;

				SetDbTypeNameFromType();
			}
		}

        // Flags --  not used for now
        

		property System::Int32 Flags
		{
			System::Int32 get()
			{
				return m_flags;
			}
		}

        // Parameter's value --  to be use by the algorithm during processing
		property Object ^ Value
		{
			Object ^ get() 
			{ 
				return m_value; 
			}
		
			void set(Object ^ value) 
			{ 
				m_value = value; 
			}
		}



    private:
        

        System::Boolean                m_isExposed;
        System::Boolean                m_isRequired;
        String ^        m_name;
        String ^        m_typeName;
        System::Type ^  m_type;
        String ^        m_description;
        String ^        m_defaultValue;
        String ^        m_valueEnumeration;
        Object ^        m_value;

        // This is always 0 for now
        System::Int32       m_flags;

        void                SetDbTypeNameFromType();


		bool				m_fHasError;
    
    // Method visible inside, hidden outside
    internal:
        static void ConvertRuntimeToVariant(IDMContextServices* in_pSvc, Object ^ value, VARIANT*  pVar);
		void	SetParameterValue(Object ^ value){m_value = value;};

    };

    [DefaultMember("Item")]
    public   ref class MiningParameterCollection sealed 
    : public IDisposable
    , public IEnumerable
    , public ICollection

    {
    public:
        MiningParameterCollection			()
        {
            m_internal = gcnew System::Collections::ArrayList();
        }

	    virtual						~MiningParameterCollection			( void )	
        { 
        }

        void        Add(MiningParameter ^   obj)
        {
            m_internal->Add( obj );
        }

	    

		property	MiningParameter ^		default[int]
		{
			MiningParameter ^ get( int index )
			{ 
				return dynamic_cast<MiningParameter^>(m_internal[index]); 
			}
			MiningParameter ^ get( String ^ name);
		}

	    


        virtual IEnumerator^                GetEnumerator()
        {
            return m_internal->GetEnumerator();
        }

        
		property	int             Count
		{
			virtual int get()
			{
				return m_internal->Count;
			}
		}

        
	
		property	bool    IsSynchronized
		{
			virtual bool    get()
			{
				return m_internal->IsSynchronized;
			}
		}

        

		property	Object ^    SyncRoot
		{
			virtual Object ^    get()
			{
				return m_internal->SyncRoot;
			}
		}

        virtual void CopyTo(Array ^ array, int index )
        {
            m_internal->CopyTo(array, index);
        }

		// Dispose method
/*		virtual void	Dispose			( bool				fDestruction )
        {
            m_internal  =   nullptr;
        }*/

	private:
        System::Collections::ArrayList  ^   m_internal;
    }; // MiningDistributionCollection


}
}
}
}
